package com.gxa.service.impl;

import com.gxa.common.R;
import com.gxa.common.StatusComment;
import com.gxa.mapper.StockInfoMapper;
import com.gxa.pojo.Warehouse;
import com.gxa.service.StockInfoService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StockInfoServiceImpl implements StockInfoService {

    R r = new R();

    @Autowired(required = false)
    private StockInfoMapper stockInfoMapper;

    @Override
    public R queryStock(Map map) {

        int currentPage = Integer.parseInt((String) map.get("currentPage"));
        int pageSize = Integer.parseInt((String) map.get("pageSize"));
        Integer newCurrentPage = (currentPage - 1) * pageSize;
        List<Map> warehouseList =  stockInfoMapper.queryStock(newCurrentPage,pageSize,map, StatusComment.STATUS);
        if(warehouseList != null){
            r.setCode(200);
            r.setMsg("success");
            r.setData(warehouseList);
            return r;
        }else {
            r.setCode(405);
            r.setMsg("系统出错了，请联系管理员");
            return r;
        }
    }
}
